If you have read the ziplist compressed list analysis I have analyzed, I think this is not a special problem. Ziplist compression lists and zipmap both use the dynamic byte allocation method to indicate the length. For example, the fixed byte representation saves a lot of space. The same problem is the complex pointer movement and character position movement. But overall
If you have read the ziplist compressed list analysis I have analyzed, I think th
ZipmapIn the Hashtable implementation, Redis introduces a ZIPMAP data structure that is guaranteed to be stored with less memory when the Hashtable is created and the elements are small, while the efficiency of the query is not greatly affected.Zipmap uses strings to implement a simple hash table to store a small number of key-value pairs.Memory layoutThe Zipmap memory layout is as follows: 1) zmlen:1 byt
This article introduces the principle and implementation of ZIPMAP in Redis. (reprint please indicate CSDN blog for breaksoftware)Basic structureZipmap is to implement the structure that holds the pair (string,string) data, which contains a header information, a series of string pairs (then a "string pair" called an "element" (ELE)) and a tail mark. The structure is represented by a graph:The structure is not used in the Redis source code to express t
I. Special encoding:
Since redis 2.2, many data types can be optimized by special encoding. Here, the storage structure can be optimized by hash, list, and sets composed of Integers to consume less space. In some cases, you can save 9/10 of the space.These special codes are completely transparent for redis usage. In fact, they are only a transaction between CPU and memory. If the memory usage is higher, the CPU consumed during data operations will naturally increase, and vice versa. Redis provi
In Redis, a hash data type stores data that is very similar to storing a record in a MySQL database, a string of field and value mapping tables that are especially good for storing objects, but field values can only be strings and other types are not supported.
The Redis hash is a string-type field and value mapping table. Its add, delete operations are all O (1) (average).Hashing is particularly useful for storing objects. Gencun each character of an object to a single string type. To save an
First, special code:
Since Redis 2.2, many data types can be optimized for storage in a special coding way. The Hash, list, and integer sets can optimize the storage structure to take up less space and, in some cases, save 9/10 of the space.These special encodings are completely transparent to the use of Redis, in fact, it is only a transaction between CPU and memory. If memory usage is higher, the CPU used to manipulate the data is more natural and vice versa. A set of configuration parameters
easier to access the entire object.
(The reason for saving memory is that when a new hash object is created, it is stored with a zipmap (also known as a small hash).
This zipmap is not actually a hash table, but zipmap than the normal hash implementation can save a lot of hash itself need some metadata storage overhead.
Although
HASH type of Redis Data Type
HASH type-Features
Redis hash is a ing table between fields and values of the string type. Its Addition and deletion operations are O (1) (average ).Hash is particularly suitable for Object Storage. Compared to saving each field of an object to a single string type. Storing an object in the hash type consumes less memory and makes it easier to access the entire object. Memory saving is because zipmap (also known as sma
min Max returns the number of scores in the specified range in the set.Zcard key returns the number of elements in the set.The zscore key element returns the score corresponding to the given element.Zremrangebyrank key min max deletes the elements in the specified range in the collection.Zremrangebyscore key min max deletes the element of the score in the specified range in the set. 6. Hash Redis hash is a ing table of field and value of the string type. It is added and deleted by O (1 )( Avera
, and vice versa.
2.2.2. Hash typeHash is a ing table between fields and values of the string type. Add and delete operations are O (1) (average ).Hash is particularly suitable for Object Storage. Each field of the object is saved as a single string type. Convert an objectThe storage in the hash type consumes less memory and makes it easier to access the entire object. The reason for saving memory is:Zipmap (also known as small hash) is used to store a new hash object. This
Redis Hash is a string-type field and value mapping table. Its add, delete operations are O (1) (average). Hash is particularly useful for storing objects. Compared to Gencun each word of an object into a single string type. Storing an object in a hash type consumes less memory and makes it easier to access the entire object. The reason for saving memory is that when a new hash object is created, it is stored with Zipmap (also known as small hash). Th
ID when the element is stored.6.Hash Set TypeRedis Hash is a string-type field and value mapping table. Its addition, delete operations are o.hash especially suitable for storing objects.Compared to Gencun each word of an object into a single string type. Storing an object in a hash type consumes less memory and makes it easier to access the entire object.The reason for saving memory is that when a new hash object is created, it is stored with Zipmap
Redis Hash is a string-type field and value mapping table. Its add, delete operations are O (1) (average). Hash is particularly useful for storing objects. Compared to Gencun each word of an object into a single string type. Storing an object in a hash type consumes less memory and makes it easier to access the entire object. The reason for saving memory is that when a new hash object is created, it is stored with Zipmap (also known as small hash). Th
Redis Hash is a string-type field and value mapping table. A key can correspond to more than one field, and one field corresponds to a value. Storing an object as a hash type can save memory more than storing each field as a string type. When a new hash object is created, it is initially stored with Zipmap (also known as small hash). This zipmap is not actually hash table, but
element.Zremrangebyrank key min max deletes the elements in the specified range in the collection.Zremrangebyscore key min max deletes the element of the score in the specified range in the set.6. hash Redis hash is a string-type field and value ing table. It is added, and the delete operation is O (1) (average). hash is particularly suitable for storing objects. Compared to saving each field of an objectSingle string type. Storing an object in the hash type consumes less memory and makes it ea
Redishash is a string ing table between fields and values of the string type. The addition and deletion operations are O (1) (average ). Hash is particularly suitable for storing
Redis hash is a ing table between fields and values of the string type. Its Addition and deletion operations are O (1) (average ). Hash is particularly suitable for storing
HASH type-Features
Redis hash is a ing table between fields and values of the string type. Its Addition and deletion operations are O (1) (averag
Memory Management OptimizationsThe Redis hash is a hashmap within value, and if the map has fewer members, the map is stored in a compact format similar to one-dimensional linearity, which eliminates the memory overhead of a large number of pointers, which control the following 2 entries in the redis.conf configuration file:Hash-max-zipmap-entries Hash-max-zipmap-value 512When value is not more than the num
scoreZrangebyscore Key min Max returns the elements of score in a given interval in the collectionZcount Key min Max returns the number of score at a given interval in the collectionZcard Key returns the number of elements in the collectionZscore key element returns the score corresponding to the given elementZremrangebyrank key min Max deletes elements in the collection that rank in a given intervalZremrangebyscore key min Max deletes elements from the collection score at a given interval6. Ha
1.3 zipmap Structure
If the redisObject type member value is of the REDIS_HASH type, when the entry of the hash is smaller than the configuration value: if the length of the hash-max-zipmap-entries or value string is less than hash-max-zipmap-value, it can be encoded into REDIS_ENCODING_ZIPMAP storage to save memory. otherwise, Dict is used for storage.
The redishash is a string-type field and a mapping table of value. A key can correspond to multiple fields, and a field corresponds to a value. Storing an object as a hash type can save memory more than storing each field as a string type. When a new hash object is created, it is initially stored with Zipmap (also known as small hash). This zipmap is not actually hash table, but
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.